#include <bits/stdc++.h>
using namespace std;

template <typename T, int N>
struct SegmentTree {
  T ans[N * 4], a[N];
  T add_tag[N];
  int ls(int p) { return p << 1; }
  int rs(int p) { return p << 1 | 1; }
  void push_up(int p) { ans[p] = ans[ls(p)] + ans[rs(p)]; }
  void build(int p, int l, int r) {
    if (l == r) {
      ans[p] = a[l];
      return;
    }
    int mid = (l + r) >> 1;
    build(ls(p), l, mid);
    build(rs(p), mid + 1, r);
    push_up(p);
  }
  void f(int p, int l, int r, T k) {
    add_tag[p] = add_tag[p] + k;
    ans[p] = ans[p] + k * (r - l + 1);
  }
  void push_down(int p, int l, int r) {
    int mid = (l + r) / 2;
    f(ls(p), l, mid, add_tag[p]);
    f(rs(p), mid + 1, r, add_tag[p]);
    add_tag[p] = 0;
  }
  void update(int nl, int nr, int l, int r, int p, T k) {
    if (nl <= l && r <= nr) {
      ans[p] = ans[p] + k * (r - l + 1);
      add_tag[p] += k;
      return;
    }
    push_down(p, l, r);
    int mid = (l + r) / 2;
    if (nl <= mid) update(nl, nr, l, mid, ls(p), k);
    if (nr > mid) update(nl, nr, mid + 1, r, rs(p), k);
    push_up(p);
  }
  T query(int q_x, int q_y, int l, int r, int p) {
    T res = 0;
    if (q_x <= l && r <= q_y) return ans[p];
    int mid = (l + r) / 2;
    push_down(p, l, r);
    if (q_x <= mid) res += query(q_x, q_y, l, mid, ls(p));
    if (q_y > mid) res += query(q_x, q_y, mid + 1, r, rs(p));
    return res;
  }
};
typedef long long ll;
SegmentTree<ll, (int)1e6 + 10> tree;
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; ++i) scanf("%lld", &tree.a[i]);
  tree.build(1, 1, n);
  while (m--) {
    ll a;
    scanf("%lld", &a);
    if (a == 1) {
      ll b, c, d;
      scanf("%lld%lld%lld", &b, &c, &d);
      tree.update(b, c, 1, n, 1, d);
    } else {
      ll e, f;
      scanf("%lld%lld", &e, &f);
      printf("%lld\n", tree.query(e, f, 1, n, 1));
    }
  }
}
